package com.hp.service;

import com.hp.bean.Customer;
import com.hp.mapper.LoginMapper;
import org.apache.ibatis.annotations.Mapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.sql.Timestamp;
import java.util.Date;
import java.util.List;
import java.util.Map;

@Service
public class LoginServiceImp implements LoginService{
    @Resource
    LoginMapper loginMapper;
    @Override
    public Customer login(String phone) {
        List<Customer> login=loginMapper.login(phone);
        if (login.size()>0){
            return login.get(0);
        }else {
            Customer customer = new Customer();
            customer.setPhone(phone);
            customer.setCreatetime(new Date());
            loginMapper.add(customer);
            return customer;
        }
    }
}
